package com.lmt.api;

import com.lmt.base.ResultData;
import com.lmt.entity.search.ResourceUploadSearch;
import com.lmt.service.ResourceUploadService;
import com.lmt.util.RedisCacheUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Date 2018/07/17
 *
 * @author MT-Lin
 */
@RestController
@RequestMapping("/ResourceUploadApi")
public class ResourceUploadApi {

	private final ResourceUploadService resourceUploadService;

	private final RedisCacheUtil redisCacheUtil;

	@Autowired
	public ResourceUploadApi(ResourceUploadService resourceUploadService, RedisCacheUtil redisCacheUtil) {
		this.resourceUploadService = resourceUploadService;
		this.redisCacheUtil = redisCacheUtil;
	}

	@RequestMapping("/search")
	public ResultData search(@RequestBody ResourceUploadSearch resourceUploadSearch) {
		String userId = redisCacheUtil.getUserId(resourceUploadSearch);
		resourceUploadSearch.setUserId(userId);
		return this.resourceUploadService.search(resourceUploadSearch);
	}
}
